Windows Management Instrumentation

Windows Management Instrumentation (WMI) consists of a set of extensions to the Windows Driver Model that provides an operating system interface through which instrumented components provide information and notification. WMI is Microsoft's implementation of the Web-Based Enterprise Management (WBEM) and Common Information Model (CIM) standards from the Distributed Management Task Force (DMTF).

WMI allows scripting languages (such as VBScript or Windows PowerShell) to manage Microsoft Windows personal computers and servers, both locally and remotely. WMI comes preinstalled in Windows 2000 and in newer Microsoft OSes. It is available as a download for Windows NT,[1] Windows 95 and Windows 98.


Get-WmiObject List

The Get-WmiObject cmdlet gets instances of WMI classes or information about the available WMI classes.

PS> Get-WmiObject -List

Win32_BIOS

The Win32_BIOS WMI class represents the attributes of the computer system's basic input/output services (BIOS) that are installed on a computer.

Get-WmiObject -Class Win32_BIOS

Win32_ComputerSystem

The Win32_ComputerSystem class represents a computer system operating in a Windows environment.

Get-WmiObject -Class Win32_ComputerSystem

Win32_NetworkAdapterConfiguration

The Win32_NetworkAdapterConfiguration class represents the attributes and behaviors of a network adapter.

Get-WmiObject -Class Win32_NetworkAdapterConfiguration

win32_logicaldisk

The win32_logicaldisk class presents information about logicaldisks, size and free space available.

get-WmiObject win32_logicaldisk DeviceID : C: DriveType : 3 ProviderName : FreeSpace : 438228828160 Size : 498396557312 VolumeName : OS DeviceID : D: DriveType : 5 ProviderName : FreeSpace : Size : VolumeName :

Use Remote WMI

The Get-WmiObject cmdlet may be used to connect to remote computers using the -ComputerName parameter, with a specified Credential if necessary.[

Get-WmiObject -Class Win32_BIOS -ComputerName 'RemoteHost' Get-WmiObject -Class Win32_BIOS -ComputerName 'RemoteHost' -Credential 'RemoteHost\Username'

Enable/Disable-PSRemoting

The Enable-PSRemoting cmdlet configures the computer to receive Windows PowerShell remote commands that are sent by using the WS-Management technology. The Disable-PSRemoting cmdlet prevents users on other computers from running commands on the local computer.

Enable-PSRemoting -Force Disable-PSRemoting -Force

Enter-PSSession

The Enter-PSSession cmdlet starts an interactive PowerShell session with a single remote computer. During the session, the commands that you type run on the remote computer, just as though you were typing directly on the remote computer. You can have only one interactive session at a time.

Enter-PSSession -Computer RemoteHost

Create a session on the local computer

This command creates a new PSSession on the local computer and saves the PSSession in the $s variable.

$s = New-PSSession

Create a session on a remote computer

This command creates a new PSSession on the Server01 computer and saves it in the $Server01 variable.

$Server01 = New-PSSession -ComputerName Server01 $s1, $s2, $s3 = New-PSSession -ComputerName Server01,Server02,Server03